package com.mvc4g.example.client.view.user;

import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.mvc4g.client.Event;
import com.mvc4g.example.client.bean.UserBean;

public class DisplayUserView extends AbstractUserView {

	private Label lastName = null;
	private Label firstName = null;
	private UserBean user = null;

	public void init(UserBean user) {
		this.user = user;
		lastName.setText(user.getLastName());
		firstName.setText(user.getFirstName());
	}

	protected Widget getLastName() {
		if(lastName == null){
			lastName = new Label();
		}
		return lastName;
	}

	protected Widget getFirstName() {
		if(firstName == null){
			firstName = new Label();
		}
		return firstName;
	}

	protected String getButtonText() {
		return "Copy";
	}

	protected void buttonAction() {
		controller.handleEvent(new Event(COPY_USER, user));
	}

}
